package com.gs.SynPatrolRep.adapter;

import android.content.Context;
import android.view.View;

import com.gs.SynPatrolRep.R;
import com.gs.SynPatrolRep.adapter.base.BaseAdapter;
import com.gs.SynPatrolRep.adapter.base.BaseViewHolder;
import com.gs.SynPatrolRep.db.dto.PalBillListDto;

import java.util.List;


public class PalBillListAdapter extends BaseAdapter<PalBillListDto> {


    public PalBillListAdapter(Context context, List<PalBillListDto> mDatas, int layoutId) {
        super(context, mDatas, layoutId);
    }

    @Override
    public void convert(BaseViewHolder holder, PalBillListDto item, final int position) {
        holder.setText(R.id.tv_num, item.getBillNum() == null ? "" : item.getBillNum());
        holder.setItemText(R.id.tv_describe,item.getBillName() == null ? "" : item.getBillName());
        holder.setText(R.id.tv_plan, item.getPlanAt() == null ? "" : item.getPlanAt());
        if (item.getCurState() != null) {
            String curStateName = item.getCurStateName() == null ? "" : item.getCurStateName();
            switch (item.getCurState()){
                case 0:
                    holder.setTextAndColor(R.id.tv_state, curStateName,R.color.deeper_red);
                    break;
                case 1:
                    holder.setTextAndColor(R.id.tv_state, curStateName,R.color.blue);
                    break;
                case 2:
                    holder.setTextAndColor(R.id.tv_state, curStateName,R.color.color_999);
                    break;
                case 3:
                    holder.setTextAndColor(R.id.tv_state, curStateName,R.color.btn_back);
                    break;
                case 4:
                    holder.setTextAndColor(R.id.tv_state, curStateName,R.color.color_a7);
                    break;
            }

        }else {
            holder.setVisibility(R.id.tv_state, View.GONE);
        }
    }
}
